﻿using Microsoft.EntityFrameworkCore.Migrations;

namespace EntityframeworkDemo.Migrations
{
    public partial class AddOrganization : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<int>(
                name: "OrganizationId",
                table: "User",
                nullable: true);

            migrationBuilder.CreateTable(
                name: "Organization",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("Sqlite:Autoincrement", true),
                    Name = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Organization", x => x.Id);
                });

            //migrationBuilder.CreateIndex(
            //    name: "IX_User_OrganizationId",
            //    table: "User",
            //    column: "OrganizationId");

            //migrationBuilder.AddForeignKey(
            //    name: "FK_User_Organization_OrganizationId",
            //    table: "User",
            //    column: "OrganizationId",
            //    principalTable: "Organization",
            //    principalColumn: "Id",
            //    onDelete: ReferentialAction.Restrict);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            //migrationBuilder.DropForeignKey(
            //    name: "FK_User_Organization_OrganizationId",
            //    table: "User");

            migrationBuilder.DropTable(
                name: "Organization");

            //migrationBuilder.DropIndex(
            //    name: "IX_User_OrganizationId",
            //    table: "User");

            migrationBuilder.DropColumn(
                name: "OrganizationId",
                table: "User");
        }
    }
}
